import java.util.Scanner;

public class grammar {
    public static int fun3(int n){
        if(n<10){
            return n;
        }
            return (n%10)+fun3(n/10);


    }

    public static void main(String[] args) {
        System.out.println(fun3(123));
    }
    public static int fun2(int n){
        if(n==1){
            return n;
        }
        return n+fun2(n-1);
    }
    public static void main9(String[] args) {
        System.out.println(fun2(10));
    }
    public static void fun(int n){
        if(n<10){
            System.out.println(n);
            return;
        }
        else{
            fun(n/10);
            System.out.println(n%10);
        }
    }
    public static void main8(String[] args) {
        fun(123);
    }

    public static void main7(String[] args) {
        double ret=0.0;
        int flag=1;
        for(int i=1;i<=100;i++){
            ret+=1.0/i*flag;
            flag=-flag;
        }
        System.out.println(ret);
    }
    //1-100出现久的个数
    public static void main6(String[] args) {
        int count=0;
        for(int i=1;i<=100;i++){
            if(i%10==9){
                count++;

            }if(i/10==9){
                count++;
            }
        }
        System.out.println(count);
    }
    //求阶乘
    public static  int facSub(int n){
        int sum=0;
        for(int i=1;i<=n;i++){
            sum+=fac(i);
        }
        return sum;

    }
    public static int fac(int n){
        int ret=1;
        for(int i=1;i<=n;i++){
            ret*=i;
        }
        return ret;
    }
    public static void main5(String[] args) {
        System.out.println(facSub(5));
    }
    //水仙花数
    public static void main4(String[] args) {
        for(int i=1;i<999999;i++){
            int count=0;
            int tmp=i;
            while(tmp!=0){
                count++;
                tmp/=10;
            }
            tmp=i;
            int sum=0;
            while(tmp!=0){
                sum+=Math.pow(tmp%10,count);
                tmp/=10;
            }
            if(sum==i){
                System.out.println(i);
            }
        }
    }
    //最大公约数
    public static void main3(String[] args) {
        Scanner scan=new Scanner(System.in);
        int a= scan.nextInt();
        int b= scan.nextInt();
        scan.close();
        int c=a%b;
        while(c!=0){
            a=b;
            b=c;
            c=a%b;

        }
        System.out.println(b);

    }
    //9*9
    public static void main2(String[] args) {

        for(int i=1;i<=9;i++){
            for(int j=1;j<=i;j++){
                System.out.print(i+"*"+j+"="+(i*j)+" ");
            }
            System.out.println();
        }

    }
    //素数
    public static void main1(String[] args) {
        Scanner scan=new Scanner(System.in);
        int num=scan.nextInt();//100
        for(int k=1;k<=num;k++){
            int i=2;
            for(;i<=Math.sqrt(k);i++){
                if(k%i==0){
                    break;
                }
            }
            if(i>Math.sqrt(k)){
                System.out.println(k+"是素数");
            }

        }

    }


}
